package com.volcreate.week2_3.no3;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * @author zxc
 * @date 2020/9/21
 */

abstract class Shape {
    public static final double PI = 3.14;

    public abstract double getPerimeter();

    public abstract double getArea();
}

class Rectangle extends Shape {

    private int width;
    private int length;

    public Rectangle(int width, int length) {
        this.width = width;
        this.length = length;
    }

    @Override
    public double getPerimeter() {
        return (length + width) * 2;
    }

    @Override
    public double getArea() {
        return length * width;
    }

    @Override
    public String toString() {
        return "Rectangle " +
                "[width=" + width +
                ", length=" + length +
                "]";
    }
}

class Circle extends Shape {

    private int radius;

    public Circle(int radius) {
        this.radius = radius;
    }

    @Override
    public double getPerimeter() {
        return PI * 2 * radius;
    }

    @Override
    public double getArea() {
        return PI * radius * radius;
    }

    public String toString() {
        return "Circle [" +
                "radius=" + radius +
                ']';
    }
}

public class Main {

    public static double sumAllArea(List<Shape> shapes) {
        double sum = 0;
        for (Shape shape : shapes) {
            sum += shape.getArea();
        }
        return sum;
    }

    public static double sumAllPerimeter(List<Shape> shapes) {
        double sum = 0;
        for (Shape shape : shapes) {
            sum += shape.getPerimeter();
        }
        return sum;
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int i = scanner.nextInt();
        scanner.nextLine();
        ArrayList<Shape> list = new ArrayList<>();
        for (; i > 0; i--) {
            String s = scanner.nextLine();
            switch (s) {
                case "rect": {
                    Rectangle rectangle = new Rectangle(scanner.nextInt(), scanner.nextInt());
                    scanner.nextLine();
                    list.add(rectangle);
                    break;
                }
                case "cir": {
                    Circle circle = new Circle(scanner.nextInt());
                    scanner.nextLine();
                    list.add(circle);
                    break;
                }
            }
        }
        System.out.println(sumAllPerimeter(list));
        System.out.println(sumAllArea(list));
        System.out.println(list);
        for (Shape shape : list) {
            System.out.println(shape.getClass() + "," + shape.getClass().getSuperclass());
        }
    }


}

